#include <textmode.h>
#include <io.h>
unsigned int ticks =0;
void div_zero()//divide by zero exception handler
{
kprint("ERROR: Divide By 0, CPU HALTED");
cli();
hlt();
}

void debug_ex()//debug exception
{
	kprint("ERROR: Debug Exception, CPU HALTED");
	cli();
	hlt();
}

void nmi()
{
	kprint("ERROR: NMI, CPU HALTED");
	cli();
	hlt();
}

void breakp_ex()
{
	kprint("TRAP: BREAKPOINT EXCEPTION, CPU HALTED");
	cli();
	hlt();
}

void idoe_ex()
{
     kprint("TRAP: INTO DETECTED OVERFLOW EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void outofb_ex()
{
     kprint("TRAP: OUT OF BOUNDS EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void invalop_ex()
{
     kprint("TRAP: INVALID OPCODE EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void nocopr_ex()
{
     kprint("TRAP: NO COPROCESSOR EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void doufal_ex()
{
     kprint("TRAP: DOUBLE FAULT EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void copsego_ex()
{
     kprint("TRAP: COPROCESSOR SEGMENT OVERRUN EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}



void badtss_ex()
{
     kprint("TRAP: BAD TSS EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void segnp_ex()
{
     kprint("TRAP: SEGMENT NOT PRESENT, CPU HALTED");
     cli();
	 hlt();
}

void stkfal_ex()
{
     kprint("TRAP: STACK FAULT EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void genpfe_ex()
{
     kprint("TRAP: GENERAL PROTECTION FAULT EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void pagfal_ex()
{
     kprint("TRAP: PAGE FAULT EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void unkint_ex()
{
     kprint("TRAP: UNKNOWN INTERRUPPT EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void coproc_ex()
{
     kprint("TRAP: COPROCESSOR FAULT EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void alignchk_ex()
{
     kprint("TRAP: ALIGNMENT CHECK EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}

void macchk_ex()
{
     kprint("TRAP: MACHINE CHECK EXCEPTION, CPU HALTED");
     cli();
	 hlt();
}


void timer_isr()
{
	ticks++;
	print_int(ticks);
}
